package com.nanrui.mutualinductor.ui.service;

import com.nanrui.mutualinductor.communicate.PacketCallback;
import com.nanrui.mutualinductor.data.Packet_57_01;
import com.nanrui.mutualinductor.domains.PTTraditionTransformerViewInfo;
import com.nanrui.mutualinductor.ui.page.DKActivity;


public class PTTraditionTransformerService {
    private DKActivity activity;

    public PTTraditionTransformerService(DKActivity paramDKActivity) {
        this.activity = paramDKActivity;
    }

    public void display(PTTraditionTransformerViewInfo ptTraditionTransformerViewInfo, Packet_57_01 paramPacket_57_01) {
        //tab1
        ptTraditionTransformerViewInfo.setsPhaseError(Float.valueOf(paramPacket_57_01.getsPhaseError()));
        ptTraditionTransformerViewInfo.setsQuadratureError(Float.valueOf(paramPacket_57_01.getsQuadratureError()));
        ptTraditionTransformerViewInfo.setsPrimaryU(Float.valueOf(paramPacket_57_01.getsWorkingVoltage()));
        ptTraditionTransformerViewInfo.setsSecondaryR(Float.valueOf(paramPacket_57_01.getsSecondaryR()));
        ptTraditionTransformerViewInfo.setsDCR(Float.valueOf(paramPacket_57_01.getsDCR()));
        ptTraditionTransformerViewInfo.setsXb(Float.valueOf(paramPacket_57_01.getsXb()));

        ptTraditionTransformerViewInfo.setsFErrors(paramPacket_57_01.getsFErrors());
        ptTraditionTransformerViewInfo.setsDErrors(paramPacket_57_01.getsDErrors());

        //tab2
        ptTraditionTransformerViewInfo.setsG(Float.valueOf(paramPacket_57_01.getsPhaseError()));
        ptTraditionTransformerViewInfo.setsB(Float.valueOf(paramPacket_57_01.getsQuadratureError()));
        ptTraditionTransformerViewInfo.setsSecondaryU(Float.valueOf(paramPacket_57_01.getsWorkingVoltage()));

        ptTraditionTransformerViewInfo.setsUErrors(paramPacket_57_01.getsUErrors());
        ptTraditionTransformerViewInfo.setsURoundErrors(paramPacket_57_01.getsURoundErrors());
        ptTraditionTransformerViewInfo.setsPhaseDisps(paramPacket_57_01.getsPhaseDisps());
        ptTraditionTransformerViewInfo.setsPhaseRoundDisps(paramPacket_57_01.getsPhaseRoundDisps());
    }

    public PTTraditionTransformerViewInfo getDefaultViewInfo() {
        PTTraditionTransformerViewInfo localVoltageTransformerViewInfo = new PTTraditionTransformerViewInfo();
        localVoltageTransformerViewInfo.setmStatus((short) 1);
        return localVoltageTransformerViewInfo;
    }

    public void queryData(PTTraditionTransformerViewInfo ptTraditionTransformerViewInfo, PacketCallback<Packet_57_01> paramPacketCallback) {
        Packet_57_01 localPacket_57_01 = new Packet_57_01();
        localPacket_57_01.setmFlag((short) 3);
        localPacket_57_01.setFrameNo((short) 01);
        localPacket_57_01.setmGrade(ptTraditionTransformerViewInfo.getmGrade());
        localPacket_57_01.setmRatedPrimary(ptTraditionTransformerViewInfo.getmRatedPrimary());
        localPacket_57_01.setmRatedSecondary(ptTraditionTransformerViewInfo.getmRatedSecondary());
        localPacket_57_01.setmMeaWinRatedLoad(ptTraditionTransformerViewInfo.getmMeaWinRatedLoad());
        localPacket_57_01.setmMeaWinMiniLoad(ptTraditionTransformerViewInfo.getmMeaWinMiniLoad());
        localPacket_57_01.setmSurWinRatedLoad(ptTraditionTransformerViewInfo.getmSurWinRatedLoad());
        localPacket_57_01.setmSurWinMiniLoad(ptTraditionTransformerViewInfo.getmSurWinMiniLoad());
        localPacket_57_01.setmPhaseAngle(ptTraditionTransformerViewInfo.getmPhaseAngle());
        this.activity.sendPacket(localPacket_57_01, paramPacketCallback);
    }

    public void resetResult(PTTraditionTransformerViewInfo ptTraditionTransformerViewInfo) {
        ptTraditionTransformerViewInfo.setsPhaseError(null);
        ptTraditionTransformerViewInfo.setsQuadratureError(null);
        ptTraditionTransformerViewInfo.setsPrimaryU(null);
        ptTraditionTransformerViewInfo.setsSecondaryR(null);
        ptTraditionTransformerViewInfo.setsDCR(null);
        ptTraditionTransformerViewInfo.setsXb(null);
        ptTraditionTransformerViewInfo.setsFErrors(null);
        ptTraditionTransformerViewInfo.setsDErrors(null);
        ptTraditionTransformerViewInfo.setsG(null);
        ptTraditionTransformerViewInfo.setsB(null);
        ptTraditionTransformerViewInfo.setsSecondaryU(null);
        ptTraditionTransformerViewInfo.setsUErrors(null);
        ptTraditionTransformerViewInfo.setsURoundErrors(null);
        ptTraditionTransformerViewInfo.setsPhaseDisps(null);
        ptTraditionTransformerViewInfo.setsPhaseRoundDisps(null);
        ptTraditionTransformerViewInfo.setsResult(null);
    }


    public void start1ndMeasure(PTTraditionTransformerViewInfo ptTraditionTransformerViewInfo, PacketCallback<Packet_57_01> paramPacketCallback) {
        Packet_57_01 localPacket_57_01 = new Packet_57_01();
        localPacket_57_01.setmFlag((short) 1);
        localPacket_57_01.setFrameNo((short) 01);
        localPacket_57_01.setmGrade(ptTraditionTransformerViewInfo.getmGrade());
        localPacket_57_01.setmRatedPrimary(ptTraditionTransformerViewInfo.getmRatedPrimary());
        localPacket_57_01.setmRatedSecondary(ptTraditionTransformerViewInfo.getmRatedSecondary());
        localPacket_57_01.setmMeaWinRatedLoad(ptTraditionTransformerViewInfo.getmMeaWinRatedLoad());
        localPacket_57_01.setmMeaWinMiniLoad(ptTraditionTransformerViewInfo.getmMeaWinMiniLoad());
        localPacket_57_01.setmSurWinRatedLoad(ptTraditionTransformerViewInfo.getmSurWinRatedLoad());
        localPacket_57_01.setmSurWinMiniLoad(ptTraditionTransformerViewInfo.getmSurWinMiniLoad());
        localPacket_57_01.setmPhaseAngle(ptTraditionTransformerViewInfo.getmPhaseAngle());
        this.activity.sendPacket(localPacket_57_01, paramPacketCallback);
    }

    public void stopMeasure(PTTraditionTransformerViewInfo ptTraditionTransformerViewInfo, PacketCallback<Packet_57_01> paramPacketCallback) {
        Packet_57_01 localPacket_57_01 = new Packet_57_01();
        localPacket_57_01.setmFlag((short) 4);
        localPacket_57_01.setFrameNo((short) 01);
        localPacket_57_01.setmGrade(ptTraditionTransformerViewInfo.getmGrade());
        localPacket_57_01.setmRatedPrimary(ptTraditionTransformerViewInfo.getmRatedPrimary());
        localPacket_57_01.setmRatedSecondary(ptTraditionTransformerViewInfo.getmRatedSecondary());
        localPacket_57_01.setmMeaWinRatedLoad(ptTraditionTransformerViewInfo.getmMeaWinRatedLoad());
        localPacket_57_01.setmMeaWinMiniLoad(ptTraditionTransformerViewInfo.getmMeaWinMiniLoad());
        localPacket_57_01.setmSurWinRatedLoad(ptTraditionTransformerViewInfo.getmSurWinRatedLoad());
        localPacket_57_01.setmSurWinMiniLoad(ptTraditionTransformerViewInfo.getmSurWinMiniLoad());
        localPacket_57_01.setmPhaseAngle(ptTraditionTransformerViewInfo.getmPhaseAngle());
        this.activity.sendPacket(localPacket_57_01, paramPacketCallback);
    }

    public void updateConfig(PTTraditionTransformerViewInfo ptTraditionTransformerViewInfo, PacketCallback<Packet_57_01> paramPacketCallback) {
        Packet_57_01 localPacket_57_01 = new Packet_57_01();
        localPacket_57_01.setmFlag((short) 0);
        localPacket_57_01.setFrameNo((short) 01);
        localPacket_57_01.setmGrade(ptTraditionTransformerViewInfo.getmGrade());
        localPacket_57_01.setmRatedPrimary(ptTraditionTransformerViewInfo.getmRatedPrimary());
        localPacket_57_01.setmRatedSecondary(ptTraditionTransformerViewInfo.getmRatedSecondary());
        localPacket_57_01.setmMeaWinRatedLoad(ptTraditionTransformerViewInfo.getmMeaWinRatedLoad());
        localPacket_57_01.setmMeaWinMiniLoad(ptTraditionTransformerViewInfo.getmMeaWinMiniLoad());
        localPacket_57_01.setmSurWinRatedLoad(ptTraditionTransformerViewInfo.getmSurWinRatedLoad());
        localPacket_57_01.setmSurWinMiniLoad(ptTraditionTransformerViewInfo.getmSurWinMiniLoad());
        localPacket_57_01.setmPhaseAngle(ptTraditionTransformerViewInfo.getmPhaseAngle());
        this.activity.sendPacket(localPacket_57_01, paramPacketCallback);
    }
}

